#!/bin/sh

unset ACLOCAL

if [ "$1" = "--clean" ]
then
	if [ -a Makefile ]
	then
		make maintainer-clean
	elif [ -a configure ]
	then
		configure && $0 --clean
	else
		bootstrap && configure && $0 --clean
	fi

	rm -rf configure libtool aclocal.m4 `find . -name Makefile.in` autom4te*.cache config/config.guess config/config.h.in config/config.sub config/depcomp config/install-sh config/ltmain.sh config/missing config/mkinstalldirs config/stamp-h config/stamp-h.in

else
	export AUTOMAKE="automake --add-missing --foreign --copy"
	autoreconf -fisv && rm -f `find . -name "*~"` && rm -f ChangeLog
	exit $?
fi
